package main

import "fmt"

type student struct {
	id    int
	name  string
	class string
}

//构造函数相当于init初始化
func newStudent(id int, name, class string) *student {
	return &student{
		id:    id,
		name:  name,
		class: class,
	}
}

type stuMgr struct {
	allStudent []*student
}

func newStuMgr() *stuMgr {
	return &stuMgr{
		allStudent: make([]*student, 0, 200),
	}
}

func (s *stuMgr) addStu(newStu *student) {
	s.allStudent = append(s.allStudent, newStu)
}
func (s *stuMgr) editStu(newStu *student) {
	for i, v := range s.allStudent {
		if newStu.id == v.id {
			s.allStudent[i] = newStu
			return
		}
	}
	fmt.Println("输入的学生id未找到")
}
func (s *stuMgr) viewStu() {
	for _, v := range s.allStudent {
		fmt.Printf("学号:%d 姓名:%s 班级:%s\n", v.id, v.name, v.class)
	}
}
